<template>
  <div class="pageox">
    <div class="loginPage">
      <div class="loginleft">
        <img src="../../../static/img_bg.png" />
      </div>
      <div class="loginright">
        <a-form labelAlign="left" autocomplete="true" :model="loginForm" @finish="onFinish">
          <h3 class="login_title">欢迎登录云仓供应链</h3>
          <a-form-item label="账户" name="mobile" :rules="[{ required: true, message: '请输入账户' }]">
            <a-input type="text" v-model:value="loginForm.mobile" placeholder="请输入账户">
              <template #prefix>
                <UserOutlined />
              </template>
            </a-input>
          </a-form-item>

          <a-form-item label="密码" name="password" :rules="[{ required: true, message: '请输入密码' }]">
            <a-input-password v-model:value="loginForm.password" placeholder="请输入密码">
              <template #prefix>
                <LockOutlined />
              </template>
            </a-input-password>
          </a-form-item>

          <a-form-item style="width: 100%">
            <a-button class="subBtn" type="primary" html-type="submit">登录</a-button>
          </a-form-item>
        </a-form>
      </div>
    </div>
  </div>
</template>

<script>
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
import { reactive } from 'vue'
import { useRouter } from 'vue-router'
import store from '../../store'
import { success } from '../../utils/function'
import { seaAdminLogin } from '../../config/api'
export default {
  components: {
    UserOutlined,
    LockOutlined
  },
  setup() {
    const router = useRouter()

    const loginForm = reactive({
      mobile: '',
      password: ''
    })

    //登录
    const onFinish = async values => {
      const res = await seaAdminLogin(values)
      const playload = res.data
      store.commit('login', playload)
      success(res.message)
      router.push({ path: '/' })
    }

    return {
      loginForm,
      onFinish
    }
  }
}
</script>

<style lang="scss">
#poster {
  /* background:url("../assets/eva.jpg") no-repeat; */
  background-position: center;
  height: 100%;
  width: 100%;
  background-size: cover;
  position: fixed;
}

body {
  margin: 0px;
  padding: 0;
}

.login-container {
  border-radius: 6px;
  background-clip: padding-box;
  margin: 90px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}

.login_title {
  margin: 0px auto 32px auto;
  text-align: center;
  color: #505458;
  font-size: 32px;
}

.loginPage {
  background: #fff;
  margin: 0 auto;
  display: flex;
  padding: 116px 64px;
  border-radius: 20px;

  .loginleft {
    width: 514px;
    height: 428px;

    img {
      width: 100%;
      height: 100%;
      display: block;
    }
  }

  .loginright {
    flex: 1;
    width: 406px;
    margin-left: 82px;

    .subBtn {
      width: 100%;
      border: none;
      height: 64px;
      background: #3c7cfc;
      font-size: 20px;
      margin-top: 20px;
      border-radius: 10px;
    }
  }
}

.pageox {
  height: 100vh;
  display: flex;
  align-items: center;
}
</style>
